package chapter02

import java.io.{BufferedWriter, File, FileInputStream, FileWriter}
import scala.io.{Source, StdIn}

object C03_FileIo{

  def main(args: Array[String]): Unit = {
    //控制台输入
    val filePath = StdIn.readLine()
    //文件读取
    Source.fromFile(filePath).foreach(print)
    val data = StdIn.readLine()
    //文件写入(吊用java api)
    val writer = new BufferedWriter(new FileWriter(filePath, true))
    writer.newLine()
    writer.write(data)
    writer.close()
    println("=================")
    Source.fromFile(filePath).foreach(print)
  }

}

